package main

import "fmt"

type PaymentFactory interface {
	CreatePayment(method string) Payment
}

type Payment interface {
	Pay(amount float64)
}

type WeiXinPayment struct {
}

func (w *WeiXinPayment) Pay(amount float64) {
	fmt.Println("微信支付", amount)
}

type AliPayPayment struct {
}

func (a *AliPayPayment) Pay(amount float64) {
	fmt.Println("支付宝支付", amount)
}

type PaymentFactoryImpl struct {
}

func (p *PaymentFactoryImpl) CreatePayment(method string) Payment {
	switch method {
	case "微信":
		return &WeiXinPayment{}
	case "支付宝":
		return &AliPayPayment{}
	default:
		return nil
	}
}

func main() {
	paymentFactory := &PaymentFactoryImpl{}
	payment := paymentFactory.CreatePayment("微信")
	payment.Pay(100)
}
